#pragma once
#include "Had5200BClass.h"
#include <thread>
#include "Ascan.h"
#include "BScanImage.h"
void AnalogOutput();
void SamplingFromTsvFile();
void SamplingFromParameter();

void BScanFromTsvFile();
void BScanFromParameter();
void CreateCscanData();
class SamplingTest{
public:
	SamplingTest(HAD5200BClass& d);
	std::thread AsyncSampling();
	void SamplingStop();
	std::thread asyncBScan();


	static const void displayParameter(const HAD5200BSamplingParam& p);
	static const std::string getHAD5200BOutputModeString(const HAD5200BOutputMode& mode) noexcept;
	static const std::string getHAD5200BEnableString(const HAD5200BEnable& enable) noexcept;

    static constexpr const char *SaveFolder = "Record"; //Save Folder
	static constexpr const WCHAR *SaveFolder_w = L"Record"; //Save Folder UFT-16
    static constexpr size_t DataNumber = 512;       //Number of data per file
    static constexpr size_t SpoolerBuffer = 1024;     //Spooler buffer size
    static void saveAScan(std::vector<Ascan>& buff);
	static void saveImage(BScan&& bscan);

private:
	std::mutex mx_;
	HAD5200BClass& daq_;
	bool sampling_stop_ = false;


    void rawSamplingLoop();
    void resamplingLoop();
    void fftLoop();
    void aScanLoop();
	void bScanLoop();
	



    static void saveRawData(std::vector<Rawdata>& buff);
    static void saveResamplingData(std::vector<ResamplingData>& buff);
    static void saveFFTdata(std::vector<FFTdata>& buff);
    

};